package main

import (
	"fmt"
	"time"
)

func main() {
	go func() {
		for {
			<-time.After(time.Second)
			fmt.Println("-- ", time.Now().Second())
		}
	}()

	ch1 := make(chan int)
	go func() {
		for i := 0; i < 5; i++ {
			<-time.After(time.Second * 1)
			ch1 <- i
		}
	}()

	for i := 0; i < 6; i++ {
		select {
		case _i := <-ch1:
			fmt.Printf("got %d from chan1\n", _i)
		case <-time.After(3 * time.Second):
			fmt.Println("3s passed")
		}
	}
	fmt.Println("done")
}
